/**
 * 应用常量定义
 */

// 应用配置
export const APP_CONFIG = {
  NAME: "CardCaptorSakura",
  VERSION: "1.0.0",
  DESCRIPTION: "多人格AI聊天助手",
  AUTHOR: "CardCaptorSakura Team",
  HOMEPAGE: "https://cardcaptorsakura.com",
  REPOSITORY: "https://github.com/cardcaptorsakura/cardcaptorsakura",
} as const;

// API 配置
export const API_CONFIG = {
  BASE_URL: import.meta.env.VITE_APP_BASE_API || "/api",
  TIMEOUT: 30000,
  RETRY_COUNT: 3,
  RETRY_DELAY: 1000,
} as const;

// 存储键名
export const STORAGE_KEYS = {
  TOKEN: "cardcaptorsakura_token",
  REFRESH_TOKEN: "cardcaptorsakura_refresh_token",
  USER_INFO: "cardcaptorsakura_user_info",
  USER_PREFERENCES: "cardcaptorsakura_user_preferences",
  CHAT_SESSIONS: "cardcaptorsakura_chat_sessions",
  CURRENT_SESSION: "cardcaptorsakura_current_session",
  THEME: "cardcaptorsakura_theme",
  LANGUAGE: "cardcaptorsakura_language",
  SIDEBAR_COLLAPSED: "cardcaptorsakura_sidebar_collapsed",
  WINDOW_SIZE: "cardcaptorsakura_window_size",
} as const;

// 路由路径
export const ROUTES = {
  HOME: "/",
  LOGIN: "/login",
  REGISTER: "/register",
  CHAT: "/chat",
  PERSONA: "/persona",
  PROFILE: "/profile",
  SETTINGS: "/settings",
  ABOUT: "/about",
  NOT_FOUND: "/404",
} as const;

// 消息类型
export const MESSAGE_TYPES = {
  TEXT: "text",
  IMAGE: "image",
  AUDIO: "audio",
  VIDEO: "video",
  FILE: "file",
  SYSTEM: "system",
  ERROR: "error",
} as const;

// 消息状态
export const MESSAGE_STATUS = {
  SENDING: "sending",
  SENT: "sent",
  DELIVERED: "delivered",
  READ: "read",
  FAILED: "failed",
} as const;

// 会话状态
export const SESSION_STATUS = {
  ACTIVE: "active",
  ARCHIVED: "archived",
  DELETED: "deleted",
} as const;

// 人格类型
export const PERSONA_TYPES = {
  ASSISTANT: "assistant",
  COMPANION: "companion",
  DOCTOR: "doctor",
  CHEF: "chef",
  TEACHER: "teacher",
  COUNSELOR: "counselor",
  ENTERTAINER: "entertainer",
  CUSTOM: "custom",
} as const;

// 人格状态
export const PERSONA_STATUS = {
  ACTIVE: "active",
  INACTIVE: "inactive",
  TRAINING: "training",
  ERROR: "error",
} as const;

// 用户角色
export const USER_ROLES = {
  USER: "user",
  VIP: "vip",
  ADMIN: "admin",
  SUPER_ADMIN: "super_admin",
} as const;

// 用户状态
export const USER_STATUS = {
  ACTIVE: "active",
  INACTIVE: "inactive",
  SUSPENDED: "suspended",
  BANNED: "banned",
} as const;

// 文件类型
export const FILE_TYPES = {
  IMAGE: ["jpg", "jpeg", "png", "gif", "bmp", "webp", "svg"],
  VIDEO: ["mp4", "avi", "mov", "wmv", "flv", "webm", "mkv"],
  AUDIO: ["mp3", "wav", "flac", "aac", "ogg", "wma"],
  DOCUMENT: ["pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt", "rtf"],
  ARCHIVE: ["zip", "rar", "7z", "tar", "gz", "bz2"],
} as const;

// 文件大小限制 (字节)
export const FILE_SIZE_LIMITS = {
  IMAGE: 10 * 1024 * 1024, // 10MB
  VIDEO: 100 * 1024 * 1024, // 100MB
  AUDIO: 50 * 1024 * 1024, // 50MB
  DOCUMENT: 20 * 1024 * 1024, // 20MB
  ARCHIVE: 50 * 1024 * 1024, // 50MB
} as const;

// 主题配置
export const THEMES = {
  LIGHT: "light",
  DARK: "dark",
  AUTO: "auto",
} as const;

// 语言配置
export const LANGUAGES = {
  ZH_CN: "zh-cn",
  EN_US: "en-us",
  JA_JP: "ja-jp",
  KO_KR: "ko-kr",
} as const;

// 通知类型
export const NOTIFICATION_TYPES = {
  SUCCESS: "success",
  INFO: "info",
  WARNING: "warning",
  ERROR: "error",
} as const;

// WebSocket 事件
export const WS_EVENTS = {
  CONNECT: "connect",
  DISCONNECT: "disconnect",
  MESSAGE: "message",
  TYPING: "typing",
  STOP_TYPING: "stop_typing",
  USER_ONLINE: "user_online",
  USER_OFFLINE: "user_offline",
  SESSION_UPDATE: "session_update",
  PERSONA_UPDATE: "persona_update",
  ERROR: "error",
} as const;

// HTTP 状态码
export const HTTP_STATUS = {
  OK: 200,
  CREATED: 201,
  NO_CONTENT: 204,
  BAD_REQUEST: 400,
  UNAUTHORIZED: 401,
  FORBIDDEN: 403,
  NOT_FOUND: 404,
  METHOD_NOT_ALLOWED: 405,
  CONFLICT: 409,
  UNPROCESSABLE_ENTITY: 422,
  TOO_MANY_REQUESTS: 429,
  INTERNAL_SERVER_ERROR: 500,
  BAD_GATEWAY: 502,
  SERVICE_UNAVAILABLE: 503,
  GATEWAY_TIMEOUT: 504,
} as const;

// 错误代码
export const ERROR_CODES = {
  NETWORK_ERROR: "NETWORK_ERROR",
  TIMEOUT_ERROR: "TIMEOUT_ERROR",
  AUTH_ERROR: "AUTH_ERROR",
  PERMISSION_ERROR: "PERMISSION_ERROR",
  VALIDATION_ERROR: "VALIDATION_ERROR",
  SERVER_ERROR: "SERVER_ERROR",
  UNKNOWN_ERROR: "UNKNOWN_ERROR",
} as const;

// 分页配置
export const PAGINATION = {
  DEFAULT_PAGE: 1,
  DEFAULT_SIZE: 20,
  MAX_SIZE: 100,
  SIZE_OPTIONS: [10, 20, 50, 100],
} as const;

// 动画配置
export const ANIMATIONS = {
  DURATION: {
    FAST: 150,
    NORMAL: 300,
    SLOW: 500,
  },
  EASING: {
    EASE: "ease",
    EASE_IN: "ease-in",
    EASE_OUT: "ease-out",
    EASE_IN_OUT: "ease-in-out",
  },
} as const;

// 响应式断点
export const BREAKPOINTS = {
  XS: 480,
  SM: 576,
  MD: 768,
  LG: 992,
  XL: 1200,
  XXL: 1600,
} as const;

// Z-Index 层级
export const Z_INDEX = {
  DROPDOWN: 1000,
  STICKY: 1020,
  FIXED: 1030,
  MODAL_BACKDROP: 1040,
  MODAL: 1050,
  POPOVER: 1060,
  TOOLTIP: 1070,
  TOAST: 1080,
} as const;

// 颜色配置
export const COLORS = {
  PRIMARY: "#409EFF",
  SUCCESS: "#67C23A",
  WARNING: "#E6A23C",
  DANGER: "#F56C6C",
  INFO: "#909399",
  TEXT: {
    PRIMARY: "#303133",
    REGULAR: "#606266",
    SECONDARY: "#909399",
    PLACEHOLDER: "#C0C4CC",
  },
  BORDER: {
    BASE: "#DCDFE6",
    LIGHT: "#E4E7ED",
    LIGHTER: "#EBEEF5",
    EXTRA_LIGHT: "#F2F6FC",
  },
  BACKGROUND: {
    BASE: "#F5F7FA",
    LIGHT: "#FAFAFA",
    WHITE: "#FFFFFF",
  },
} as const;

// 正则表达式
export const REGEX = {
  EMAIL: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
  PHONE: /^1[3-9]\d{9}$/,
  PASSWORD: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*(),.?":{}|<>]).{8,}$/,
  USERNAME: /^[a-zA-Z0-9_]{3,20}$/,
  URL: /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/,
  IPV4: /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
  HEX_COLOR: /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,
} as const;

// 默认配置
export const DEFAULTS = {
  AVATAR: "/images/default-avatar.png",
  PERSONA_AVATAR: "/images/default-persona.png",
  LANGUAGE: LANGUAGES.ZH_CN,
  THEME: THEMES.AUTO,
  PAGE_SIZE: PAGINATION.DEFAULT_SIZE,
  CHAT_INPUT_PLACEHOLDER: "请输入消息...",
  SEARCH_PLACEHOLDER: "搜索...",
  LOADING_TEXT: "加载中...",
  EMPTY_TEXT: "暂无数据",
  ERROR_TEXT: "出错了，请稍后重试",
} as const;

// 快捷键
export const SHORTCUTS = {
  SEND_MESSAGE: "Enter",
  NEW_LINE: "Shift+Enter",
  SEARCH: "Ctrl+K",
  NEW_SESSION: "Ctrl+N",
  TOGGLE_SIDEBAR: "Ctrl+B",
  TOGGLE_THEME: "Ctrl+Shift+T",
  FOCUS_INPUT: "Ctrl+I",
  ESCAPE: "Escape",
} as const;

// 人格预设
export const PERSONA_PRESETS = {
  ASSISTANT: {
    name: "智能助手",
    description: "专业的AI助手，能够回答各种问题并提供帮助",
    avatar: "/images/personas/assistant.png",
    personality: "专业、友善、乐于助人",
    skills: ["问答", "分析", "建议", "解决问题"],
  },
  COMPANION: {
    name: "情感陪伴",
    description: "温暖的陪伴者，提供情感支持和心理慰藉",
    avatar: "/images/personas/companion.png",
    personality: "温暖、体贴、善解人意",
    skills: ["倾听", "安慰", "鼓励", "情感支持"],
  },
  DOCTOR: {
    name: "医疗顾问",
    description: "专业的医疗顾问，提供健康咨询和建议",
    avatar: "/images/personas/doctor.png",
    personality: "专业、严谨、关怀",
    skills: ["健康咨询", "症状分析", "用药建议", "预防保健"],
  },
  CHEF: {
    name: "美食专家",
    description: "专业的烹饪专家，分享美食制作技巧",
    avatar: "/images/personas/chef.png",
    personality: "热情、创新、专业",
    skills: ["食谱推荐", "烹饪技巧", "营养搭配", "美食文化"],
  },
} as const;

// 导出所有常量
export default {
  APP_CONFIG,
  API_CONFIG,
  STORAGE_KEYS,
  ROUTES,
  MESSAGE_TYPES,
  MESSAGE_STATUS,
  SESSION_STATUS,
  PERSONA_TYPES,
  PERSONA_STATUS,
  USER_ROLES,
  USER_STATUS,
  FILE_TYPES,
  FILE_SIZE_LIMITS,
  THEMES,
  LANGUAGES,
  NOTIFICATION_TYPES,
  WS_EVENTS,
  HTTP_STATUS,
  ERROR_CODES,
  PAGINATION,
  ANIMATIONS,
  BREAKPOINTS,
  Z_INDEX,
  COLORS,
  REGEX,
  DEFAULTS,
  SHORTCUTS,
  PERSONA_PRESETS,
};
